﻿<phone:PhoneApplicationPage
    x:Class="TravisCI.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!-- Progress Bar -->
        <ProgressBar IsIndeterminate="True" Visibility="{Binding ProgressBarVisible}" VerticalAlignment="Top" Margin="0,15,0,0"></ProgressBar>

        <Grid x:Name="AuthenticationGrid" Visibility="{Binding AuthenticationVisible}" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel Grid.Row="0" Margin="12,17,0,28">
                <TextBlock Text="Enter Authentication Details" Style="{StaticResource PhoneTextNormalStyle}"/>
            </StackPanel>

            <!--ContentPanel - place additional content here-->
            <Grid Grid.Row="1" Margin="12,0,12,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                
                <StackPanel Grid.Row="0">
                    <TextBlock Margin="10,0,0,0" TextWrapping="Wrap" Text="GitHub Username" VerticalAlignment="Top"/>
                    <TextBox x:Name="Username" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top"/>
                    <TextBlock TextWrapping="Wrap" Text="GitHub Password" VerticalAlignment="Top"/>
                    <PasswordBox x:Name="Password" VerticalAlignment="Top"/>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Content="Ok" Grid.Column="0" Click="AuthenticationButton_Ok_Click" />
                        <Button Content="Cancel" Grid.Column="1" Click="AuthenticationButton_Cancel_Click" />
                    </Grid>
                </StackPanel>
                <ScrollViewer Grid.Row="1">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap" Text="Why enter your password?" FontWeight="Bold" TextDecorations="Underline" Margin="0,32,0,0" FontSize="24" />
                        <TextBlock TextWrapping="Wrap" Text="This application will not save your GitHub credentials in any way. If you click 'Ok', they are used to authenticate to GitHub once through the authorization API described here:" Margin="0,12,0,0" />
                        <HyperlinkButton TargetName="_blank" Content="GitHub Developer API" NavigateUri=" http://developer.github.com/v3/oauth/#create-a-new-authorization" Margin="0,6,0,0" />
                        <TextBlock TextWrapping="Wrap" Text="GitHub will return a token that allows an application to access your private repositories. You can view this token in your GitHub account page and revoke it from there at any time." Margin="0,6,0,0" />
                        <TextBlock TextWrapping="Wrap" Text="The GitHub authentication token is saved by this application and passed to TravisCI to request an access token through their authorization API, which is described here:" Margin="0,16,0,0" />
                        <HyperlinkButton TargetName="_blank" Content="TravisCI Developer API" NavigateUri="https://api.travis-ci.org/docs/#POST%20/auth/github" Margin="0,6,0,0" />
                        <TextBlock TextWrapping="Wrap" Text="Travis returns a token that this application uses to access the build data from your private builds." Margin="0,6,0,0" />
                        <TextBlock TextWrapping="Wrap" Text="At no time will we use your credentials to do anything other than authenticate through these APIs in order to access build data from TravisCI." Margin="0,16,0,0"/>
                    </StackPanel>
                </ScrollViewer>
            </Grid>
        </Grid>

        <!--Pivot Control-->
        <controls:Pivot x:Name="Pivot" Title="Travis-CI" Margin="0" ItemsSource="{Binding Items}" Visibility="{Binding MainVisible}">
            <controls:Pivot.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Margin="0,5,0,0"/>
                </DataTemplate>
            </controls:Pivot.HeaderTemplate>
            <controls:Pivot.ItemTemplate>
                <DataTemplate>
                    <ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Builds}" SelectionChanged="SelectBuild">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17" Width="432" Height="78">
                                    <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Height="32" Width="32">
                                        <Rectangle.Fill>
                                            <SolidColorBrush Color="{Binding ResultColor}"/>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                    <TextBlock Text="{Binding ShortMessage}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="48,-32,12,0"/>
                                    <TextBlock Text="{Binding EventType}" TextWrapping="Wrap" Margin="48,-12,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </DataTemplate>
            </controls:Pivot.ItemTemplate>
        </controls:Pivot>

    </Grid>

    <!--<system:String x:Key="ImagesLocation">Assets/Images/</system:String>-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Add OpenSource Project" Click="ApplicationBarAdd_Click" />
                <shell:ApplicationBarMenuItem Text="Add TravisPro Project" Click="ApplicationBarAddPrivate_Click" />
                <shell:ApplicationBarMenuItem Text="Remove this Project" Click="ApplicationBarRemove_Click"/>
                <shell:ApplicationBarMenuItem x:Name="ResetGitHubTokenButton" Text="Reset GitHub Token" Click="ApplicationBarResetToken_Click" IsEnabled="false" />
                <shell:ApplicationBarMenuItem Text="About" Click="ApplicationBarAbout_Click" />
            </shell:ApplicationBar.MenuItems>
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton Text="Refresh" IconUri="appbar.refresh.rest.png" Click="ApplicationBarRefresh_Click" />
            </shell:ApplicationBar.Buttons>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>